const tokenName = 'fyuser_token'
const infoName = 'fyuser_info'
export function getToken() {
	let value = ''
	try {
		value = uni.getStorageSync(tokenName)

	} catch (e) {

	}
	return value
}
export function setToken(token) {
	uni.setStorageSync(tokenName, token)
}
export function clearToken() {
	uni.removeStorageSync(tokenName)
}


export function getUserInfo() {
	let value = null
	try {
		value = JSON.parse(uni.getStorageSync(infoName))

	} catch (e) {

	}
	return value
}
export function setUserInfo(token) {
	uni.setStorageSync(infoName, JSON.stringify(token))
}
export function clearUserInfo() {
	uni.removeStorageSync(infoName)
}

export function getChatList(loginId) {
	let value = []
	try {
		value = JSON.parse(uni.getStorageSync(`chatList_${loginId}`))

	} catch (e) {

	}
	return value
}
export function setChatList(loginId, chatlist) {
	var key = `chatList_${loginId}`
	uni.setStorageSync(key, JSON.stringify(chatlist))
}
export function setChatLog(loginId, chatUserId, msgData) {
	uni.setStorageSync(`chatdetail_${loginId}_${chatUserId}`, JSON.stringify(msgData))
}
export function getChatLog(loginId, chatUserId) {

	let value = []
	try {
		value = JSON.parse(uni.getStorageSync(`chatdetail_${loginId}_${chatUserId}`))

	} catch (e) {

	}
	return value

}
export function getSearchLog() {
	let value = []
	try {
		value = JSON.parse(uni.getStorageSync(`fy_search_log`))

	} catch (e) {

	}
	return value
}
export function setSearchLog(data){
	uni.setStorageSync('fy_search_log', JSON.stringify(data))
}